import java.util.Scanner;

public class HotelBooking {
    public static void main(String[] args) {
        Receptionist receptionist = new Receptionist();
        //receptionist.print();
        System.out.println("欢迎使用酒店管理系统");
        System.out.println("功能编号对应的功能：[1]查看所有房间列表。[2]订房。[3]退房。[0]退出系统。");
        Scanner s = new Scanner(System.in);
        //死循环，一直可以用
        while(true) {
            System.out.println("请输入功能编号：");
            int i = s.nextInt();
            if (i == 1) {
                receptionist.print();
            } else if (i == 2) {
                System.out.println("请输入房间号");
                int no = s.nextInt();
                System.out.print("文梦甜已经定了");
                receptionist.reserve(no);
                System.out.println("房号是：" + no);
            } else if (i == 3) {
                System.out.println("请输入房间号");
                int no = s.nextInt();
                System.out.print("文梦甜已经退了");
                receptionist.quit(no);
                System.out.println("房号是：" + no);
            } else if (i == 0) {
                System.out.println("退出系统");
                return;
            } else {
                System.out.println("出错了");
            }
        }

    }
}

class Receptionist{          //初始化应该放在构造方法当中
    String name;
    Room[][] rooms;

    //楼房信息列表
    public Receptionist(){
        //盖楼了
        //Room[][] rooms = new Room[5][12];  //抛出空指针异常，这里相当于重新创建了Room[][]对象，并不是类最开始的那个
        rooms = new Room[5][12];
        for (int i = 0; i < rooms.length; i++) {
            for (int j = 0; j < rooms[i].length; j++) {
                if( i == 0 ){
                    rooms[i][j] = new Room((i + 1) * 100 + (j + 1), "双床房", false);
                }else if (i == 1 ){
                    rooms[i][j] = new Room((i + 1) * 100 + (j + 1), "大床房", false);
                }else if (i == 2 ){
                    rooms[i][j] = new Room((i + 1) * 100 + (j + 1), "圆床房", false);
                }else if (i == 3 ){
                    rooms[i][j] = new Room((i + 1) * 100 + (j + 1), "投影房", false);
                }else if (i == 4 ){
                    rooms[i][j] = new Room((i + 1) * 100 + (j + 1), "浴缸房", false);
                }
            }

        }

    }

    //打印所有房间
    public void print(){
        for (int i = 0; i < rooms.length; i++) {
            for (int j = 0; j < rooms[i].length; j++) {
                Room r = rooms[i][j];
                System.out.print(r.toString() + "\t");
            }
            System.out.println();
        }
    }
    //预订
    public void reserve(int no){
        rooms[no / 100 - 1][no % 100 - 1].space = true ;
        String sty = rooms[no / 100 - 1][no % 100 - 1].style;
        System.out.println(sty);
    }
    //退房
    public void quit(int no){
        rooms[no / 100 - 1][no % 100 - 1].space = false ;
        String sty = rooms[no / 100 - 1][no % 100 - 1].style;
        System.out.println(sty);
    }

}

class Room{
    //房间编号
    int no;
    //房间类型
    String style;
    //房间是否空闲，0表示空闲，1表示不空闲
    boolean space;

    public Room() {

    }

    public Room(int no, String style, boolean space) {
        this.no = no;
        this.style = style;
        this.space = space;
    }

    public String toString() {
        //把一个变量塞到一个字符串当中
        return "[" + no + "," + style + "," + (space ? "占用" : "空闲") + "]";
    }
}